#pragma once

#include <stdint.h>

// https://sadistech.com/nesromtool/romdoc.html
typedef struct {
	uint8_t*	data_prgrom;
	uint8_t*	data_chrrom;
	uint32_t	count_prgrom_16kb;
	uint32_t	count_chrrom_8kb;
	uint8_t		mapper_number;
	uint8_t		vmirroring;
	uint8_t		four_screen;
	uint8_t		save_ram;
	uint8_t		reserved[4];
} sfc_rom_info_t;

// https://wiki.nesdev.org/w/index.php/NES_2.0#Header
typedef struct {
	uint32_t	id;
	uint8_t		count_prgrom_16kb;
	uint8_t		count_chrrom_8kb;
	uint8_t		control1;
	uint8_t		control2;
	uint8_t		reserved[8];
} sfc_nes_header_t;

// nes 开头魔数， 'N' 'E' 'S' '\x1A'
// 小端机，数字的低位放在低地址处
static const uint32_t NES_MAGIC_NUM = 0x1A53454E;

// control flag1
enum {
	SFC_NES_VMIRROR = 0X01,
	SFC_NES_SAVEROM = 0X02,
	SFC_NES_TRAINER = 0X04,
	SFC_NES_4SCREEN = 0X08
} control_flag1_mask;

enum {
	SFC_NES_VS_UNISYSTEM = 0X01,
	SFC_NES_Playchoice10 = 0X02
} control_flag2_mask;